<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户列表')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
	
	<div class="container-div">
		<div class="row">
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: ztree-js" />
	<script th:inline="javascript">
		var prefix = ctx + "system/user";

		$(function() {
		    queryUserList();
		});

		function queryUserList() {
		    var options = {
		        url: prefix + "/shuserList",
		        sortOrder: "desc",
		        modalName: "用户",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'userId',
		            title: '用户ID'
		        },
		        {
		            field: 'loginName',
		            title: '登录名称'
		        },
		        {
		            field: 'userName',
		            title: '用户名称'
		        },
		        {
		            field: 'dept.deptName',
		            title: '部门'
		        },
		        {
		            field: 'email',
		            title: '邮箱',
		            visible: false
		        },
		        {
		            field: 'phonenumber',
		            title: '手机'
		        },
		        {
                    field: 'idcardno',
                    title: '身份证'
                },
                {
                    field: 'path',
                    title: '附件',
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0)" onclick="window.open(\''+ctx + row.path+'\')">点击下载</a>';
                    }
                },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="updateTG(\'' + row.userId + '\')"><i class="fa fa-edit"></i>通过</a> ');
		                actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="updateBH(\'' + row.userId + '\')"><i class="fa fa-remove"></i>驳回</a> ');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		}
		
		
		/* 通过 */
		function updateTG(userId) {
			$.modal.confirm("确认要通过吗？", function() {
				$.operate.post(prefix + "/shuserSave", { "userId": userId, "shstatus": 1 });
		    })
		}

		// 驳回
		function updateBH(userId) {
			$.modal.confirm("确认要驳回吗？", function() {
				$.operate.post(prefix + "/shuserSave", { "userId": userId, "shstatus": 2 });
		    })
		}
	</script>
</body>
</html>